package com.project.oj.controller;

import com.project.oj.recommend.impl.TextAnalysisService;
import com.project.oj.recommend.impl.Word2VecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TextAnalysisController {
    @Autowired
    private TextAnalysisService textAnalysisService;

    @Autowired
    private Word2VecService word2VecService;

    @PostMapping("/processText")
    public List<String> processText(@RequestParam String text) {
        return textAnalysisService.preprocessText(text);
    }

    @PostMapping("/similarity")
    public double getSimilarity(@RequestParam String word1, @RequestParam String word2) {
        return word2VecService.calculateSentenceSimilarity(word1, word2);
    }
}

